﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VehicleMaintenance.Models;
using System.Data.Entity;
using VehicleMaintenance.BaseInfo;
using VehicleMaintenance.Transaction;
using VehicleMaintenance.Query;

namespace VehicleMaintenance
{
	public partial class MainForm : VehicleMaintenance.Framework.BaseForm
	{

		#region 构造函数

		/// <summary>
		/// 
		/// </summary>
		public MainForm()
		{
			InitializeComponent();
		}

		#endregion 构造函数

		#region 窗体事件

		private void Form1_Load(object sender, EventArgs e)
		{
			try
			{
				CarDBContext db = new CarDBContext();
				Models.BaseInfo info = db.BaseInfo.FirstOrDefault(p => p.ID > 0);
				if (info != null)
				{
					this.toolStripStatusLabel1.Text = info.Name;
				}
				else
				{
					this.toolStripStatusLabel1.Text = "未注册";
					BaseInfo.BaseInfoForm form = new BaseInfoForm();
					form.ShowDialog(this);
				}
				this.toolStripStatusLabel3.Text = DateTime.Now.ToString("yyyy年MM月dd日dddd");
			}
			catch (Exception ex)
			{
				this.ShowInfo(ex.Message);
			}
		}

		private void 店面信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			BaseInfo.BaseInfoForm form = new BaseInfo.BaseInfoForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 员工信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			StaffListForm form = new StaffListForm(false);
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 客户信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			CustomerListForm form = new CustomerListForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 车辆信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			CarListForm form = new CarListForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 车辆型号管理ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			BaseInfo.CarTypeForm form = new CarTypeForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 车辆故障信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			MaintenanceCategoriesForm form = new MaintenanceCategoriesForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}


		private void 零件信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			GoodListForm form = new GoodListForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 零件类别ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			GoodTypeForm form = new GoodTypeForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		#endregion 窗体事件

		private void 零件入库ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PurchaseBillForm form = new PurchaseBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 库存退货ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PurchaseReturnsBillForm form = new PurchaseReturnsBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 零件销售ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SalesBillForm form = new SalesBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 销售退货ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SalseReturnsBillForm form = new SalseReturnsBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void btnRegister_Click(object sender, EventArgs e)
		{
			MainBillForm form = new MainBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void btnWork_Click(object sender, EventArgs e)
		{
			WorkForm form = new WorkForm("已登记");
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void btnSettle_Click(object sender, EventArgs e)
		{
			WorkForm form = new WorkForm("修理中");
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 销售单查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SalesQueryForm form = new SalesQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 零件报损ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			DamageBillForm form = new DamageBillForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 报损单查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			DamageQueryForm form = new DamageQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 入库单查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PurchaseQueryForm form = new PurchaseQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 退货单查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			PurchaseReturnsQueryForm form = new PurchaseReturnsQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 维修查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			RecipientQueryForm form = new RecipientQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 销售退货查询ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			SalseReturnsQueryForm form = new SalseReturnsQueryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 库存信息ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			InventoryForm form = new InventoryForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 应收帐款ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			NeedChargedForSaleForm form = new NeedChargedForSaleForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 应付张狂ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			NeedChargedForBuyForm form = new NeedChargedForBuyForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}

		private void 现金ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			CashAccountsForm form = new CashAccountsForm();
			form.ShowInTaskbar = false;
			form.ShowDialog(this);
		}
	}
}
